﻿@using ECGadmin.Common
@using ECGadmin.WebUI.CustomHelpers
@using ECGadmin.WebUI.Models
@model IEnumerable<NewsListAdminDto>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_layout.cshtml";
}

<nav>
    <div id="jCrumbs" class="breadCrumb module">
        <ul>
            <li><a href="@Url.Action("Index", "Home")"><i class="bootstrap icon-home"></i></a></li>
            <li><a href="javascript:void(0)">Danh sách tin</a> </li>
        </ul>
    </div>
</nav>

<div class="toolBox">
    @Html.ToolBox(new List<object> { new Add { ClassCss = "Add", ActionName = "/News/AddNews" } })
</div>
<div style="overflow:hidden;">
    <table class="table-odd" cellspacing="0" cellpadding="0">
        <thead>
            <tr>
                <th style="width: 35px; text-align: center; padding-left: 0;">@Html.CheckBox("chkAll")</th>
                <th style="width: 30px">STT</th>
                <th style="width: 80px">Ảnh</th>
                <th>Tiêu đề</th>
                <th>Danh mục</th>
                <th style="width: 90px">Ngày tạo</th>
                <th style="width: 50px">Nổi bật</th>
                <th style="width: 70px">Kích hoạt</th>
                <th></th>
            </tr>
        </thead>
        @foreach (var item in Model)
        {
        <tr class="@string.Format("bn-{0}", item.Id) trHeight">
            <td class="bgTableFirst">
                @Html.CheckBox("chkItem")
            </td>
            <td>@item.STT</td>
            <td>
                <img src="/upload/NewsDetail/@item.ImagePath?width=45&height=45" width="45" height="45" />
            </td>
            <td style="text-align: left;">
                <a href="@Url.Action("EditNews", "News", new { ID = item.Id })" title="@item.Title">@item.Title</a>
                <div class="info-ad-qv">
                    <a href="@Url.Action("EditNews", "News", new { id = @item.Id })">Sửa</a> |
                    <a href="">Sửa nhanh</a> |
                    @Ajax.ActionLink("Xóa", "DeleteNews", "News", new { id = item.Id }, new AjaxOptions
                                                                                                       {
                                                                                                           Confirm = "Bạn chắc chắn muốn xóa danh mục này!",
                                                                                                           OnSuccess = "AjaxReturnDataDelNews"
                                                                                                       }, new { @class = "icon-del2 ad-qv-txt2" }) |
                    <a href="">Xem</a>
                </div>
            </td>
            <td>
                <a href="@Url.Action("EditNewsCategory", "NewsCategory", new { ID = item.CategoryId })" title="@item.CateName">@item.CateName</a>
            </td>
            <td>
                @item.CreateDate.ToString("dd/MM/yyyy")
            </td>
            <td>
                <input type="checkbox" id="@item.Id" @string.Format("{0}", item.Hot ? "checked" : "") />
            </td>
            <td>
                <input type="checkbox" id="@item.Id" @string.Format("{0}", item.Active ? "checked" : "") />
            </td>
            <td align="center">
                @Ajax.ActionLink("Xóa", "DeleteNews", "News", new { id = item.Id }, new AjaxOptions
                                                                                                       {
                                                                                                           Confirm = "Bạn chắc chắn muốn xóa danh mục này!",
                                                                                                           OnSuccess = "AjaxReturnDataDelNews"
                                                                                                       }, new { @class = "icon-delete bootstrapTangoSmall", title = "chỉnh sửa" })
            </td>
        </tr>
        }
    </table>
</div>
<div class="p-paging">
    @Html.PageLinks((PageInfo)ViewBag.PageInfo, i => Url.Action("Index", "News", new { page = i }))
</div>

@section scripts
{
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script type="text/javascript">
        function AjaxReturnDataDelNews(data) {
            if (data) {
                window.location = document.URL;
            }
        }
    </script>
}

